<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/ajax.js"></script>
</head>

<body>
    <button class="get">get</button>
    <button class="post">post</button>
</body>
<script>
    var getBtn = document.getElementsByClassName("get")[0];
    var postBtn = document.getElementsByClassName("post")[0];


    getBtn.onclick = function () {

        var wd = ""; // 搜索的关键词 (默认 "" => 查询所有数据)
        var col = "id"; // 排序的列名(默认id)
        var type = "asc"; // 排序的方式(默认升序)
        var page = 1;    // 默认显示第一页
        var size = 5;    // 默认每页显示五条

        $.ajax({
            url: "../php/searchGradeOrderLimit.php",
            data: `wd=${wd}&col=${col}&type=${type}&page=${page}&size=${size}`,
            // async: true,
            dataType: "json",
            success: function (res) {
                console.log("请求结束", res);
            }
        })

        $.ajax({
            // type:"get",
            url: "../php/searchGradeOrderLimit.php",
            data: {
                wd: wd,
                col,
                type,
                page,
                size,
            },
            // async: true,
            dataType: "json",
            success: function (res) {
                console.log("请求结束", res);
            }
        })

    }

    postBtn.onclick = function () {
        var user = "a123123"; // 'a123123'
        var pwd = "123123";

        if (user && pwd) {
            $.ajax({
                type: "post",
                url: "../php/login.php",
                data: { user: user, pwd },
                // async:true,
                dataType: "json",
                success: function (res) {
                    console.log(res);
                }
            })
        }
    }


</script>

</html>